﻿
namespace KinonekoSoftware.Foundation.UI.Controls.Buttons
{
    public class TextButton : ForestButtonBase
    {

        public static readonly StyledProperty<bool> IsOpenContextMenuProperty;

        static TextButton()
        {
            IsOpenContextMenuProperty = AvaloniaProperty.Register<TextButton, bool>(nameof(IsOpenContextMenu));
        }

        protected override void OnClick()
        {
            if (ContextMenu is not null)
            {
                ContextMenu.PlacementTarget = this;
                ContextMenu.Placement       = PlacementMode.Bottom;
                ContextMenu.Open();
            }
            base.OnClick();
        }

        public bool IsOpenContextMenu
        {
            get => GetValue(IsOpenContextMenuProperty);
            set => SetValue(IsOpenContextMenuProperty, value);
        }
    }
}